/*
 * @Author: wang cong wangc9832@163.com
 * @Date: 2023-05-10 10:16:11
 * @LastEditors: wang cong wangc9832@163.com
 * @LastEditTime: 2023-06-02 19:52:33
 * @FilePath: /ams-front/src/api/asset/amsProjectManage.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */
import { BasicFetchResult } from '../model/baseModel';
import { defHttp } from '@/utils/http/axios';
import { downloadBlob } from '@/utils/file/download';
const api = '/amsProject';

/**
 * @description: 通过id查单条项目
 * @param {any} params
 * @return {*}
 */
export const detail = (id?: any) => defHttp.get({ url: api + '/detail/' + id });
/**
 * 查询项目档案分页
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const page = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/page', params });
/**
 * 查询项目档案不分页
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const list = (params?: any) =>
  defHttp.get<BasicFetchResult<any>>({ url: api + '/list', params });
/**
 * 添加项目档案
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const add = (params?: any) =>
  defHttp.post({ url: api + '/add', params });
/**
 * 修改项目档案
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const edit = (params?: any) =>
  defHttp.post({ url: api + '/edit', params });

export const audit = (id: string, isPass: string, bpmRemark: string) => {
  return defHttp.post({ url: api + '/audit', params: { id, isPass, bpmRemark } });
}

export const abandon = (id: string) => {
  return defHttp.post({ url: `${api}/abandon/${id}` });
}
/**
 * 删除项目档案
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const del = (ids: string[]) =>
  defHttp.post({ url: api + '/delete', params: ids });
/**
 * 导出项目档案
 * @author gxt
 * @date 2023-05-10 09:49:47
 */
export const exp = (params?: any) => {
  return new Promise<void>((resolve, reject) => {
    defHttp
      .get(
        { responseType: 'blob', url: api + '/export', params },
        { isReturnNativeResponse: true }
      )
      .then((res) => {
        downloadBlob(res);
        resolve();
      })
      .catch(() => {
        reject();
      });
  });
};
